function createHidden(name, value) {
	return new Element('input', { type: 'hidden', value: value, name: name });
}

function resizeLightviewAjax(width, height){
    Lightview.innerDimensions = Lightview.getHiddenDimensions($('ajaxForm'));
    if (width) 
        Lightview.innerDimensions['width'] += width;
    if (height) 
        Lightview.innerDimensions['height'] += height;
    new Effect.Event({
        queue: Lightview.queue,
        afterFinish: Lightview.resizeWithinViewport.bind(Lightview)
    });
}

function handleAjaxNonSubmit(event, ajaxForm, onComplete){
    params = (ajaxForm ? ajaxForm : $('ajaxForm')).getInputs().reject(function(el){
        return el.hasClassName('ajax-nonsubmit');
    });
	params.push(Event.element(event));
	    
    new Ajax.Request((ajaxForm ? ajaxForm : $('ajaxForm')).readAttribute('action'), {
        evalJS: true,
        parameters: Form.serializeElements(params),
		onComplete: onComplete
    });
}

function lightbox(action, params, handler){
    if (typeof(window['Tips']) != "undefined") 
        Tips.hideAll();
    
    Lightview.show({
        href: action,
        rel: 'ajax',
        options: {
            menubar: false,
            autosize: true,
            topclose: true,
            keyboard: false,
            overflow: 'hidden',
            ajax: {
                parameters: params,
                onComplete: handler
            }
        }
    });
}
